package com.project.webpage.controller;


import com.github.pagehelper.PageInfo;
import com.project.webpage.aop.TagLog;
import com.project.webpage.dto.SearchByMonthParam;
import com.project.webpage.dto.SearchByRqParam;
import com.project.webpage.dto.SearchByRqRangeParam;
import com.project.webpage.service.ForecastTotalService;
import com.project.webpage.util.RestResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/webpage/forecast/")
public class ForecastTotalController extends BaseController {

    @Resource
    ForecastTotalService forecastTotalService;

    /**
     * 按日列表查询
     */
    @PostMapping("daily/page")
    @TagLog(operation = 0, content = "查询线路预报准确率按日统计列表")
    public RestResult page(@RequestBody SearchByRqParam param) {
        this.getPage(true, param);
        return RestResult.ok(new PageInfo<>(forecastTotalService.getListForPage(param)));
    }

    /**
     * 按日导出列表
     */
    @PostMapping("daily/output")
    @TagLog(operation = 5, content = "导出线路预报准确率统按日计列表")
    public RestResult output(@RequestBody SearchByRqParam param) {
        this.getPage(false, param);
        return RestResult.ok(forecastTotalService.getListForPage(param));
    }

    /**
     * 按月统计列表查询
     */
    @PostMapping("monthly/page")
    @TagLog(operation = 0, content = "查询线路预报准确率按月统计列表")
    public RestResult monthlyPage(@RequestBody SearchByMonthParam param) {
        this.getPage(true, param);
        return RestResult.ok(new PageInfo<>(forecastTotalService.getMonthlyListForPage(param)));
    }

    /**
     * 按月统计导出列表
     */
    @PostMapping("monthly/output")
    @TagLog(operation = 5, content = "导出线路预报准确率按月统计列表")
    public RestResult monthlyOutput(@RequestBody SearchByMonthParam param) {
        this.getPage(false, param);
        return RestResult.ok(forecastTotalService.getMonthlyListForPage(param));
    }

    /**
     * 企业预报准确率按日统计列表查询
     */
    @PostMapping("company/daily/page")
    @TagLog(operation = 0, content = "查询企业预报准确率按日统计列表")
    public RestResult dailyPage(@RequestBody SearchByRqParam param) {
        this.getPage(true, param);
        return RestResult.ok(new PageInfo<>(forecastTotalService.getCompanyDailyListForPage(param)));
    }

    /**
     * 企业预报准确率按日统计导出列表
     */
    @PostMapping("company/daily/output")
    @TagLog(operation = 5, content = "导出企业预报准确率按日统计列表")
    public RestResult dailyOutput(@RequestBody SearchByRqParam param) {
        this.getPage(false, param);
        return RestResult.ok(forecastTotalService.getCompanyDailyListForPage(param));
    }

    /**
     * 企业预报准确率按月统计列表查询
     */
    @PostMapping("company/monthly/page")
    @TagLog(operation = 0, content = "查询企业预报准确率按月统计列表")
    public RestResult dailyPage(@RequestBody SearchByMonthParam param) {
        this.getPage(true, param);
        return RestResult.ok(new PageInfo<>(forecastTotalService.getCompanyMonthlyListForPage(param)));
    }

    /**
     * 企业预报准确率按月统计导出列表
     */
    @PostMapping("company/monthly/output")
    @TagLog(operation = 5, content = "导出企业预报准确率按月统计列表")
    public RestResult dailyOutput(@RequestBody SearchByMonthParam param) {
        this.getPage(false, param);
        return RestResult.ok(forecastTotalService.getCompanyMonthlyListForPage(param));
    }
}
